package com.reeygu.base.entity;

public class SaleTicket {
    private int number = 30;
    //操作方法，卖票（通过字段 synchronized 进行加锁）
    public synchronized void sale() {
        if(number > 0) {
            System.out.println(Thread.currentThread().getName() + " 卖出1张票，剩余:" + (number--));
        }
    }
}
